<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Cache-Control" content="no-cache,no-store,must-revalidate,post-check=0,ptr-check=0">
<title>发布作品(名家)</title>
<link href="../style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script src="../js/artDialog.js?skin=gray"></script>
<script src="../js/artDialog.iframeTools.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>

<script type="text/javascript">

$(function(){

	$("#paintingLink").click(function(){
		var s_Id = 2;
		if(checkChooseSharp()){
			s_Id = $("input[name='painting.sharpInfo.id']:checked").val();
		}else{
			alert("请先选择画框形状");
			return false;
		}
		art.dialog.open('${ctx}/fileUpload!uploadPrepare.do?imgType=painting&sharpId='+s_Id,{title:'上传作品图片',width:800,height:550},false);
    });
    
});

	/************  提交表单 ******************/
	function checkForm() {

		if (!checkChooseSharp()) {
			alert("请选择画框形状");
			return false;
		}

		var picImage = $("#picImage").val();
		if( picImage == "" ){
			alert("请上传作品图片。");
			return false;
		}
		
		var title = $.trim($("#title").val());
		if (title == "") {
			$("#title").focus();
			alert("请填写作品名称。");
			return false;
		}

		if (window.confirm("确认提交？")) {
			$.ajax({
				type:'POST',
				url:'${ctx }/painting/save.do',
				async : false, //ajax同步
				data:$("#publishPaintingForm").serialize(),//序列化表单里所有的内容
				success: function(data){
					if(data == '0000'){
						alert("作品发布成功！");
						var win = art.dialog.open.origin;//来源页面
						win.location.reload();
						return false;
					}else{
						alert("作品发布失败！");
						return false;
					}
				}
			});
		}
	}

</script>
</head>

<body style="background: #fff">
<form action="${ctx }/painting/save.do" method="post" id="publishPaintingForm" name="publishPaintingForm">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
      <tr>
        <td colspan="3" class="bt14A" align="center">填写名家作品资料</td>
      </tr>
      <tr>
        <td class="bt14A" align="right"><span class="style20">* </span>作品名称：</td>
        <td class="bt14A"><input name="painting.title" type="text" size="20" id="title" maxlength="40"></td>
        <td width="360" rowspan="13" valign="top">
	          <table width="360" height="384"  border="0" align="center" cellpadding="0">
	            <tr>
	              <td bgcolor="#FFFFFF" align="center">
	              	<div id="photoTd" style="width: 200px;height: 300px;border: 1px solid #CCCCCC;"></div>
	              </td>
	            </tr>
	          </table>
          </td>
      </tr>
      <tr>
        <td class="bt14A" align="right"><span class="style20">*</span> 画框形状：</td>
        <td class="bt14A">
	            <c:forEach items="${sharpInfoList}" var="sharpInfo"  varStatus="status">
				       <input onclick="choosePaintType('${sharpInfo.id }')" type="radio" name="painting.sharpInfo.id" value="${sharpInfo.id }"/>${sharpInfo.name }
            	</c:forEach>
        </td>
      </tr>
      <tr>
        <td class="bt14A" align="right"><span class="style20">*</span> 上传作品：</td>
        <td class="bt14A"><span class="style18"><a id="paintingLink" style="cursor: pointer;color: red">上传</a></span></td>
      </tr>
      <%--<tr>
        <td class="bt14A" align="right">尺 寸：</td>
        <td class="bt14A"><input name="painting.width" type="text" size="4" id="width">×
         				  <input name="painting.hight" type="text" size="4" id="height">cm
        </td>
      </tr>
       --%>
      <tr>
        <td width="160">&nbsp;</td>
        <td style="padding: 15px 0px 20px 5px;"><img src="../images/an24.gif"  style="cursor: pointer ;border: 0"  width="114" height="31"  onclick="checkForm()"> 
          <!-- 隐藏域 begin -->
	         	<input name="painting.imageInfo.id" type="hidden"  id="picImage">
	         	<input name="painting.painter.id" type="hidden" id="painter" value="${p.id }">
	       <!-- 隐藏域 end -->
	     </td>
      </tr>
</table>
</form>
</body>
</html>
